//
//  AVPlayerManager.h
//  Douyin
//
//  Created by Qiao Shi on 2018/7/30.
//  Copyright © 2018年 Qiao Shi. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>

@interface AVPlayerManager:NSObject
@property (nonatomic, strong) NSMutableArray<AVPlayer *>   *playerArray;  //用于存储AVPlayer的数组

+ (AVPlayerManager *)shareManager;
+ (void)setAudioMode;
- (void)play:(AVPlayer *)player;
- (void)pause:(AVPlayer *)player;
- (void)pauseAll;
- (void)replay:(AVPlayer *)player;
- (void)removeAllPlayers;

@end


typedef NS_ENUM(NSUInteger, HJVideoPlayerStatus) {
    HJVideoPlayerStatusUnload,      // 未加载
    HJVideoPlayerStatusPrepared,    // 准备播放
    HJVideoPlayerStatusLoading,     // 加载中
    HJVideoPlayerStatusPlaying,     // 播放中
    HJVideoPlayerStatusPaused,      // 暂停
    HJVideoPlayerStatusEnded,       // 播放完成
    HJVideoPlayerStatusError        // 错误
};

@class HJVideoPlayer;

@protocol HJVideoPlayerDelegate <NSObject>

- (void)player:(HJVideoPlayer *)player statusChanged:(HJVideoPlayerStatus)status;

- (void)player:(HJVideoPlayer *)player currentTime:(float)currentTime totalTime:(float)totalTime progress:(float)progress;

@end

@interface HJVideoPlayer : NSObject

@property (nonatomic, weak) id<HJVideoPlayerDelegate> delegate;

@property (nonatomic, assign) HJVideoPlayerStatus status;

@property (nonatomic, assign) BOOL isPlaying;


/**
 根据指定url在指定视图上播放视频
 
 @param playView 播放视图
 @param url 播放地址
 */
- (void)playVideoWithView:(UIView *)playView url:(NSString *)url;

/**
 停止播放并移除播放视图
 */
- (void)removeVideo;

/**
 暂停播放
 */
- (void)pausePlay;

/**
 恢复播放
 */
- (void)resumePlay;

/**
 重新播放
 */
- (void)resetPlay;

@end
